<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>反馈建议</title>
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="email=no">
    <meta http-equiv="X-UA-Compatible" content="chrome=1" />
    <link href="/res/style/simpleui.min.css?v=20170704" rel="stylesheet" type="text/css">
    <link href="/res/style/my/suggest.css?v=20170704" rel="stylesheet" type="text/css">
</head>

<body>
	<input type="hidden" id="orderNo" value="${orderNo}" >
	<div class="form">
        <div class="content">
            <textarea placeholder="请输入投诉或者建议的内容，我们会尽快处理。"></textarea>
            <div>0/500</div>
        </div>

        <button id="submitButton" type="button" class="btn primary">匿名提交</button>
	</div>
	
	<div class="result" style="display:none">
	    <div class="content">
	        <div class="wrap">
                <i class="icon-success"></i>
                <h1>提交成功</h1>
                <div class="remark">
                    我们会尽快处理您的问题<br/>
                    您的反馈将是我们进步的动力
                </div>
	        </div>
	    </div>
	    <button id="goIndex" type="button" class="btn primary">返回首页</button>
	</div>
	<script type="text/javascript" src="/js/commonJs.js?v=20170704"></script>
	<script type="text/javascript" src="/js/commonFoot.js?v=20170704"></script>
	<script>
	
	function GetRequest() {   
		   var url = location.search; //获取url中"?"符后的字串   
		   var theRequest = new Object();   
		   if (url.indexOf("?") != -1) {   
		      var str = url.substr(1);   
		      strs = str.split("&");   
		      for(var i = 0; i < strs.length; i ++) {   
		         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);   
		      }   
		   }   
		   return theRequest;   
		}  
	
    $(function() {
    	var flag=true; 
        //字数统计
        $('textarea').on('input', function() {
            var length = $(this).val().length;
            if(length <= 500) {
            	var param = $(this).val();
            	var regRule = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig;
           	   	if(regRule.test(param)) {
           	       param = param.replace(regRule, "");
           	       $("textarea").val(param);
           	       //alert("不支持表情");
           	   	} 
           	 	flag=true;
                $(this).next('div').removeClass('sui-red').text(length + '/500');
            } else {
                $(this).next('div').attr('class', 'sui-red').text('字数太多了。');
                flag=false;
            }
        });
        //提交
        $('#submitButton').on('click', function() {
        	
        	var Request = new Object();
            Request = GetRequest();
            var orderNo,businessType;
            orderNo = Request['orderNo'];
            businessType = Request['businessType'];
        	
       		var text=$("textarea").val();
       		var INTERCITY = '17'; // 城际网约车
       		var INNERCITY = '18'; // 同城网约车
       		if(text==''){
       			$.toast("输入内容不能为空");
       		}else if(flag){
        		//api url       		
        		var urlStr = SERVER_URL_PREFIX+'/Comment/addComplaint';        		
            	//current page param
            	var dataObj = {
            			content: $("textarea").val(),
                     	//orderNo: $("#orderNo").val(),
            		};
            	if (orderNo !=''){
            		dataObj.orderNo = orderNo;
            	}
            	if (businessType !=''){
            		dataObj.businessType = businessType;
            		if (businessType == INTERCITY || businessType == INNERCITY){
            			urlStr = SERVER_URL_PREFIX+'/hail/Comment/addComplaint';
            		}
            	}
            	//merge page param and common param,generate request param
            	dataObj = genReqData(urlStr, dataObj);
            	
            	 $.ajax({
                     type: 'POST',
                     url:urlStr,
                     data:dataObj,
                     dataType:  "json",
                     success: function(result){
                    	 if(result&&result.code==0){
                    		 setTimeout(function() {
                                  $('body').addClass('result-body');
                                  $('.form').hide();
                                  $('.result').show();
                                  window.location='/index';
                              }, 800);
                    	 }else{
                    		 $.alert((result&&result.message) || "未知错误");
                    	 }
                    	 
                     },
               });
        	}
        });
        
        $('#goIndex').on('click', function(){
        	location.href = '/index';
        })
    })
    </script>
</body>
</html>
